package si.yun.service.impl;

import com.google.gson.Gson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import si.yun.dao.HomeDao;
import si.yun.dao.PersonalDao;
import si.yun.entity.*;
import si.yun.service.HomeService;
import si.yun.utils.KeyWordFilter;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: ThinkManage
 * @description: 首页业务层
 * @author: 崔晓晨
 * @create: 2021-10-15 09:27
 **/
@Service
@PropertySource({"config/config.properties"})
public class HomeServiceImpl implements HomeService {
    @Autowired
    private HomeDao homeDao;
    @Autowired
    private PersonalDao personalDao;

    /*获取服务器路径*/
    @Value("${path1}")
    private String path;
    @Autowired
    private RedisTemplate redisTemplate;
    /**
     * @Description  查询主页轮播图 查找Redis缓存中的数据，有就返回，没有就查找数据库中的数据，有就更新缓存并返回数据，没有就返回没有
     * @return java.util.List<si.yun.entity.SyCarousel>
     * @Date 2021/10/14 16:44
     **/
    @Override
    public List<SyCarousel> selCarouselInfo() {
        List<SyCarousel> syCarouseles = homeDao.selCarouselInfo();
        for(SyCarousel lists:syCarouseles){
            lists.setImgAddress(path+lists.getImgAddress());
            if(lists.getConnect()==null){
                lists.setConnect("");
            }else{
                lists.setConnect(path+lists.getConnect());
            }
        }
        return syCarouseles;
    }
    /**
     * @Description  查找视频详情  前后端
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date 2021/10/15 9:26
     **/
    @Override
    public List<Map<String, Object>> selCourseInfo() {
        List<Map<String, Object>> list = homeDao.selCourseInfo();
        List<Map<String, Object>> list1 = homeDao.selCourseInfoBefore();
        for(Map<String, Object> ma:list1){
            list.add(ma);
        }
        int i = 0;
        for(Map<String, Object> map:list){
            Object course_price = map.get("course_price");
            Object course_nprice = map.get("course_nprice");
            if(course_price==null){
                map.put("course_price","免费");
            }
            if(course_nprice==null){
                map.put("course_nprice","免费");
            }
            map.put("url",path+map.get("url"));
            String trueName = (String) map.get("true_name");
            String true_name = trueName.substring(0, 1);
            map.put("true_name",true_name+"老师");
            i++;
        }
        return list;
    }
    /**
     * @Description  获取课程的详细信息
     * @return java.util.Map<java.lang.String,java.lang.Object> 
     * @Date 2021/10/26 11:33
     **/
    @Override
    public Map<String, Object> selCourseInformation(Integer courseId) {
        Map<String, Object> map = homeDao.selCourseInformation(courseId);
        Object uId = map.get("userId");
        Integer userId= Integer.parseInt(uId.toString());
        Object tp = map.get("type");
        Integer type= Integer.parseInt(tp.toString());
        if(type==2){
            //前端审核人员信息
            SyBeforeUser beforeUser = homeDao.selBeforeUserInfo(userId);
            String realName = beforeUser.getRealName();
            String avatarUrl = beforeUser.getAvatarUrl();
            String remarks = beforeUser.getRemarks();
            String true_name = realName.substring(0, 1);
            map.put("trueName",true_name+"老师");
            map.put("userAvatarUrl",path+avatarUrl);
            map.put("userRemarks",remarks);
        }else if(type==3){
            //后台管理端人员
            SyUser user = homeDao.selBackUserInfo(userId);
            String trueName = user.getTrueName();
            String avatarUrl = user.getAvatarUrl();
            String freestyle = user.getFreestyle();
            String true_name = trueName.substring(0, 1);
            map.put("trueName",true_name+"老师");
            map.put("userAvatarUrl",path+avatarUrl);
            map.put("userRemarks",freestyle);
        }
        map.put("courseUrl",path+map.get("courseUrl"));
        map.put("url",path+map.get("url"));
        return map;
    }
    /**
     * @Description  判断某一用户是否已经点赞
     * @return java.lang.Integer
     * @Date 2021/10/27 9:00
     **/
    @Override
    public Integer selIfLikeNum(Integer userId, Integer courseId) {
        Integer num =  homeDao.selIfLikeNum(userId,courseId);
        return num;
    }
    /**
     * @Description  点赞视频
     * @return java.lang.Integer
     * @Date 2021/10/27 11:49
     **/
    @Override
    public Integer addLikeCourseNum(Integer userId, Integer courseId) {
        //添加记录
        Integer add = homeDao.addLikeCourseNum(userId, courseId);
        //更新课程数据
        Integer upd = updCourseLokeNum(courseId);
        return add;
    }
    /**
     * @Description  取消视频点赞
     * @return java.lang.Integer 
     * @Date 2021/10/27 16:51
     **/
    @Override
    public Integer delCourseLikeNum(Integer userId, Integer courseId) {
        Integer del = homeDao.delCourseLikeNum(userId, courseId);
        //更新课程数据
        Integer upd = updCourseLokeNum(courseId);
        return del;
    }
    /**
     * @Description  更新课程数据
     * @return java.lang.Integer
     * @Date 2021/10/27 16:51
     **/
    @Transactional
    public Integer updCourseLokeNum(Integer courseId){
        Integer upd = homeDao.updCourseLokeNum(courseId);
        return upd;
    }


    /**
     * @Description 判断用户是否收藏视频
     * @return java.lang.Integer
     * @Date 2021/10/27 19:09
     **/
    @Override
    public Integer selColCourseIF(Integer userId, Integer courseId) {
        Integer num =  homeDao.selColCourseIF(userId,courseId);
        return num;
    }
    /**
     * @Description  收藏视频
     * @return java.lang.Integer
     * @Date 2021/10/27 19:11
     **/
    @Override
    public Integer addColCourseInfo(Integer userId, Integer courseId) {
        //添加记录
        Integer add = homeDao.addColCourseInfo(userId, courseId);
        //更新课程数据
        Integer upd = updCourseColNum(courseId);
        return add;
    }
    /**
     * @Description  取消收藏
     * @return java.lang.Integer
     * @Date 2021/10/27 19:11
     **/
    @Override
    public Integer delColCourseInfo(Integer userId, Integer courseId) {
        Integer del = homeDao.delColCourseInfo(userId, courseId);
        //更新课程数据
        Integer upd = updCourseColNum(courseId);
        return del;
    }
    /**
     * @Description  同步数据
     * @return java.lang.Integer
     * @Date 2021/10/27 16:51
     **/
    @Transactional
    public Integer updCourseColNum(Integer courseId){
        Integer upd = homeDao.updCourseColNum(courseId);
        return upd;
    }
    /**
     * @Description  判断该用户是否分享过该视频
     * @return java.lang.Integer
     * @Date 2021/10/29 14:47
     **/
    @Override
    public Integer selShareInfoIf(Integer userId, Integer courseId) {
        Integer ifNum = homeDao.selShareInfoIf(userId, courseId);
        return ifNum;
    }
    /**
     * @Description  插入分享数据
     * @return java.lang.Integer 
     * @Date 2021/10/29 14:47
     **/
    @Override
    public Integer addCourseShare(Integer userId, Integer courseId, Integer shareType) {
        Integer add = homeDao.addCourseShare(userId, courseId, shareType);
        //同步数据
        Integer upd = updCourseShareNum(courseId);
        return add;
    }
    /**
     * @Description  同步分享数据
     * @return java.lang.Integer
     * @Date 2021/10/29 14:46
     **/
    @Transactional
    public Integer updCourseShareNum(Integer courseId){
        Integer upd = homeDao.updCourseShareNum(courseId);
        return upd;
    }

    /**
     * @Description  获取当前课程下的相关目录
     * @return java.util.Map<java.lang.String,java.lang.Object>
     * @Date 2021/10/28 15:40
     **/
    @Override
    public List<Map<String,Object>> selCourseClassInfo(Integer courseId) {
        Map<String, Object> map = homeDao.selCourseClassInfo(courseId);
        Integer classId = (Integer)map.get("classId");
        //获取目录下的的所有课程
        List<Map<String, Object>> list = homeDao.selClassCourseList(classId);
        for(Map<String, Object> m:list){
            m.put("className",map.get("name"));
            m.put("classId",classId);
        }
        return list;
    }
    /**
     * @Description  获取课程下的评论
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date 2021/11/1 13:44
     **/
    @Override
    public List<Map<String, Object>> selCourseComments(Integer courseId,Integer userId) {
        List<Map<String, Object>> courseComments = homeDao.selCourseComments(courseId);
        List<Map<String, Object>> list1 = homeDao.selCommentLikeIf(courseId, userId);
        //处理铭感词
        KeyWordFilter.initPattern();
        for(Map<String,Object> list:courseComments){
            Integer userType = (Integer) list.get("userType");
            Integer userIdes = (Integer) list.get("userId");
            if(userType==2){
                SyBeforeUser beforeUser = homeDao.selBeforeUserName(userIdes);
                list.put("nickname",beforeUser.getNickname());
                if(beforeUser.getAvatarUrl()!=null && beforeUser.getAvatarUrl().length()!=0 && beforeUser.getAvatarUrl()!="null"){
                    if(beforeUser.getAvatarUrl().indexOf("http") == -1){
                        list.put("avatarUrl",path+beforeUser.getAvatarUrl());
                    }else{
                        list.put("avatarUrl",beforeUser.getAvatarUrl());
                    }
                }else{
                    list.put("avatarUrl","");
                }
            }else if(userType==3){
                SyUser user = homeDao.selBackUserName(userIdes);
                list.put("nickname",user.getTrueName());
                if(user.getAvatarUrl()!=null && user.getAvatarUrl().length()!=0){
                    if(user.getAvatarUrl().indexOf("http") == -1){
                        list.put("avatarUrl",path+user.getAvatarUrl());
                    }else{
                        list.put("avatarUrl",user.getAvatarUrl());
                    }
                }else{
                    list.put("avatarUrl","");
                }
            }
            String content = (String) list.get("content");
            String newContent = KeyWordFilter.doFilter2(content);
            list.put("content",newContent);
            list.put("isLikeShow",false);
        }
        for(int a=0;a<courseComments.size();a++){
            int id = (int) courseComments.get(a).get("id");
            for(int i = 0;i<list1.size();i++){
                int commentLikeId = (int) list1.get(i).get("commentId");
                if(commentLikeId==id){
                    courseComments.get(a).put("isLikeShow",true);
                }
            }
        }
        return courseComments;
    }
    /**
     * @Description  点赞评论
     * @return java.lang.Integer
     * @Date 2021/11/1 18:52
     **/
    @Override
    public Integer addCommentLike(Integer commentId, Integer userId, Integer courseId) {
        Integer add = homeDao.addCommentLike(commentId, userId, courseId);
        Integer upd = updCommentCountNum(courseId, commentId);
        return add;
    }
    /**
     * @Description  取消评论
     * @return java.lang.Integer
     * @Date 2021/11/1 18:58
     **/
    @Override
    public Integer delCommentLike(Integer commentId, Integer userId, Integer courseId) {
        //取消评论
        Integer delCommentLike = homeDao.delCommentLike(commentId, userId, courseId);
        Integer upd = updCommentCountNum(courseId, commentId);
        return delCommentLike;
    }
    /**
     * @Description  同步评论点赞总数
     * @return java.lang.Integer
     * @Date 2021/11/1 20:07
     **/
    @Transactional
    public Integer updCommentCountNum(Integer courseId,Integer commentId){
        //同步评论点赞总数
        Integer updCommentCountNum = homeDao.updCommentCountNum(courseId, commentId);
        return updCommentCountNum;
    }
    /**
     * @Description  获取课程下的评论总数
     * @return java.lang.Integer
     * @Date 2021/11/1 19:35
     **/
    @Override
    public Integer selCommentCountNum(Integer courseId) {
        //获取课程下的评论总数
        Integer selCommentCountNum  = homeDao.selCommentCountNum(courseId);
        return selCommentCountNum;
    }
    /**
     * @Description  添加留言
     * @return java.lang.Integer
     * @Date 2021/11/2 10:22
     **/
    @Override
    public Integer addCommentInfo(Integer userId, Integer courseId, String content) {
        content = KeyWordFilter.doFilter2(content);
        Integer add = homeDao.addCommentInfo(userId, courseId, content);
        return add;
    }
    /**
     * @Description
     * @return java.lang.Integer
     * @Date 2021/11/2 14:46
     **/
    @Override
    public Integer updCommentStatusDel(Integer commentId, Integer userId, Integer courseId) {
        //删除个人评论 更改状态为删除
        Integer upd = homeDao.updCommentStatusDel(commentId,userId,courseId);
        Integer del = delCommentLikeStatus(commentId, courseId);
        return upd;
    }
    /**
     * @Description  删除被删除的评论的点赞量
     * @return java.lang.Integer
     * @Date 2021/11/2 14:48
     **/
    @Transactional
    public Integer delCommentLikeStatus(Integer commentId, Integer courseId){
        Integer del = homeDao.delCommentLikeStatus(commentId, courseId);
        return del;
    }
    /**
     * @Description  优惠券使用查询
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date 2021/11/4 10:44
     **/
    @Override
    public List<Map<String, Object>> selCouponUserInfo(Integer userId, Integer productType ,Integer courseNprice) {
        List<Map<String, Object>> list = homeDao.selCouponUserInfo(userId, productType);
        List<Map<String,Object>> couponList = new ArrayList<>();
        for(Map<String, Object> map:list){
            map.put("overdueDate",map.get("endDate"));
            Integer couponType = (Integer) map.get("couponType");
            if(couponType==3){
                BigDecimal couponPrice = (BigDecimal) map.get("couponPrice");
                Integer price = couponPrice.intValue();
                if(courseNprice>=price) {
                    map.put("isRadioShow",true);
                    couponList.add(map);
                }
            }else if(couponType == 2){
                BigDecimal couponMoney = (BigDecimal) map.get("couponMoney");
                Integer money = couponMoney.intValue();
                if(courseNprice>=money){
                    map.put("isRadioShow",true);
                    couponList.add(map);
                }
            }
        }
        return couponList;
    }
    /**
     * @Description  获取个人拥有的不能使用的优惠券
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>> 
     * @Date 2021/11/4 11:44
     **/
    @Override
    public List<Map<String, Object>> selAllCouponInfo(Integer userId, Integer productType,Integer courseNprice) {
        List<Map<String, Object>> list = homeDao.selCouponUserInfo(userId, productType);
        List<Map<String,Object>> couponList = new ArrayList<>();
        for(Map<String, Object> map:list){
            map.put("overdueDate","长期有效");
            Integer couponType = (Integer) map.get("couponType");
            if(couponType==3){
                BigDecimal couponPrice = (BigDecimal) map.get("couponPrice");
                Integer price = couponPrice.intValue();
                if(courseNprice<price) {
                    map.put("isRadioShow",false);
                    couponList.add(map);
                }
            }else if(couponType == 2){
                BigDecimal couponMoney = (BigDecimal) map.get("couponMoney");
                Integer money = couponMoney.intValue();
                if(courseNprice<money){
                    map.put("isRadioShow",false);
                    couponList.add(map);
                }
            }
        }
        return couponList;
    }
    /**
     * @Description  添加购物订单
     * @return java.lang.Integer
     * @Date 2021/11/5 14:52
     **/
    @Override
    public Integer addCourseOrder(SyUserOrderUsed userOrder) {
        //获取当先购买用户是否在指定课程下评论
        Integer orderType = userOrder.getOrderType();
        Integer productCount = userOrder.getProductCount();
        if(productCount==0 && productCount==null){
            userOrder.setProductCount(1);
        }
        if(orderType == 2){
            //判断是否评论过
            Integer comment = homeDao.selUserIdCommentNum(userOrder.getUserId(),userOrder.getProductId(),orderType);
            if(comment==0){
                userOrder.setComment(2);
            }else{
                userOrder.setComment(3);
            }
            //添加课程订单
            Integer add = homeDao.addCourseOrder(userOrder);
            //判断是否使用了优惠券
            if(userOrder.getUsedId()!=0 && userOrder.getUsedId()!=null){
                //更新优惠券的使用情况
                Integer upd = updCouponUsedStatus(userOrder.getUsedId(), userOrder.getUserId(), userOrder.getOrderId());
            }
            return add;
        }else if(orderType == 3){
            //如果是商品需要添加商品的收货地址
            //获取商品的收货地址
            Map<String, Object> address = homeDao.selPrUserAddress(userOrder.getUserId());
            //收货人
            String recipientName = (String) address.get("recipientName");
            //收货人电话
            String contactNumber = (String) address.get("contactNumber");
            //收货人居住的省份
            Integer province = (Integer) address.get("province");
            String addressName = "";
            if(province!=null && province!=0){
                Map<String, Object> map = homeDao.selAddressName(province);
                addressName = (String) map.get("addressName");
            }
            //市
            Integer city = (Integer) address.get("city");
            String mapcityName = "";
            if(city!=null && city!=0){
                Map<String, Object> mapcity = homeDao.selAddressName(city);
                mapcityName = (String) mapcity.get("addressName");
            }
            //区
            Integer area = (Integer) address.get("area");
            String mapareaName = "";
            if(area!=null && area!=0){
                Map<String, Object> maparea = homeDao.selAddressName(area);
                mapareaName = (String) maparea.get("addressName");
            }
            //收货人详细地址
            String specificAddress = (String) address.get("specificAddress");
            String receivingAddress = addressName+mapcityName+mapareaName+specificAddress;
            userOrder.setReceivingAddress(receivingAddress);
            userOrder.setReceiverUser(recipientName);
            userOrder.setReceiverPhone(contactNumber);
            Integer add = null;
            if(userOrder.getDoUseShoppingCart()==3){
                Integer type = 4;//4 在评论中属于商品评论
                //判断是否评论过
                Integer comment = homeDao.selUserIdCommentNum(userOrder.getUserId(),userOrder.getProductId(),type);
                if(comment==0){
                    userOrder.setComment(2);
                }else{
                    userOrder.setComment(3);
                }
                //添加商品订单
                add = homeDao.addProductOrder(userOrder);
                //判断是否使用了优惠券
                if(userOrder.getUsedId()!=0 && userOrder.getUsedId()!=null){
                    //更新优惠券的使用情况
                    Integer upd = updCouponUsedStatus(userOrder.getUsedId(), userOrder.getUserId(), userOrder.getOrderId());
                }
            }else if(userOrder.getDoUseShoppingCart()==2){
                //设置购物车订单为已评论
                userOrder.setComment(3);
                //添加购物车专属订单
                add = homeDao.addProductShopOrder(userOrder);
                if(add!=0){
                    List<Integer> keyIdProductId = userOrder.getKeyIdProductId();
                    List<Integer> KeyIdShoppingCart = userOrder.getKeyIdShoppingCart();
                    for(int i=0;i<keyIdProductId.size();i++){
                        userOrder.setProductId(keyIdProductId.get(i));
                        Map<String, Object> map = personalDao.selOrderProInfo(keyIdProductId.get(i), KeyIdShoppingCart.get(i));
                        BigDecimal currentpriceProduct = (BigDecimal) map.get("currentpriceProduct");
                        int productNum = (int) map.get("productNum");
                        userOrder.setProductCount(productNum);
                        userOrder.setLogisticsFee(currentpriceProduct);
                        //添加购物车商品扩展表
                        addShopOrderInfo(userOrder);
                    }
                }
                //判断是否使用了优惠券
                if(userOrder.getUsedId()!=0 && userOrder.getUsedId()!=null){
                    //更新优惠券的使用情况
                    Integer upd = updCouponUsedStatus(userOrder.getUsedId(), userOrder.getUserId(), userOrder.getOrderId());
                }
            }
            return add;
        }
        return null;
    }
    /**
     * @Description  更改优惠券的使用情况
     * @return java.lang.Integer 
     * @Date 2022/1/15 16:11
     **/
    @Transactional
    public Integer updCouponUsedStatus(Integer usedId,Integer userId,Integer orderId){
        Integer upd = homeDao.updCouponUsedStatus(usedId,userId,orderId);
        return upd;
    }
    /**
     * @Description  添加购物车专属订单的扩展商品
     * @return java.lang.Integer 
     * @Date 2022/1/15 16:12
     **/
    @Transactional
    public Integer addShopOrderInfo(SyUserOrderUsed userOrder){
        Integer add = homeDao.addShopOrderInfo(userOrder);
        return null;
    }
    /**
     * @Description  付款成功后更改订单状态
     * @return java.lang.Integer
     * @Date 2021/11/8 10:23
     **/
    @Override
    public Integer updCourseOrderStatus(SyPaySuccessInfo map) {
        String orderNo = map.getOrderNo();
        Integer userId = map.getUserId();
        Map<String, Object> type = homeDao.selOrderType(orderNo, userId);
        Integer orderType = (Integer) type.get("orderType");
        if(orderType==2){
            map.setOrderStatus(3);
        }else if(orderType==3){
            map.setOrderStatus(4);
        }
        Integer upd = homeDao.updCourseOrderStatus(map);
        return upd;
    }
    /**
     * @Description  更新用户消费金额
     * @return java.lang.Integer
     * @Date 2021/12/14 10:48
     **/
    @Override
    public Integer updUserConsumption(Integer userId, BigDecimal totalAmount) {
        Integer updtwo = homeDao.updUserConsumption(userId, totalAmount);
        return updtwo;
    }
    /**
     * @Description  免费商品付款成功后更改订单状态
     * @return java.lang.Integer
     * @Date 2021/11/25 8:48
     **/
    @Override
    public Integer updCourseFreeOrderStatus(SyPaySuccessInfo map) {
        String orderNo = map.getOrderNo();
        Integer userId = map.getUserId();
        Map<String, Object> type = homeDao.selOrderType(orderNo, userId);
        Integer orderType = (Integer) type.get("orderType");
        if(orderType==3){
            map.setOrderStatus(4);
        }
        Integer upd = homeDao.updCourseFreeOrderStatus(map);
        return upd;
    }

    /**
     * @Description  取消订单
     * @return java.lang.Integer
     * @Date 2021/11/12 13:31
     **/
    @Override
    public Integer updOrderStatus(Integer orderId, String remarks) {
        Integer status = homeDao.updOrderStatus(orderId, remarks);
        return status;
    }
    /**
     * @Description  获取未付款的订单
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>> 
     * @Date 2021/11/12 16:12
     **/
    @Override
    public List<Map<String, Object>> selWaitPayOrderInfo() {
        //获取未付款的订单
        List<Map<String,Object>> selWaitPayOrderInfo  = homeDao.selWaitPayOrderInfo();
        return selWaitPayOrderInfo;
    }
    /**
     * @Description  判断该用户是否拥有指定视频的播放资格
     * @return java.util.Map<java.lang.String,java.lang.Object> 
     * @Date 2021/12/8 13:51
     **/
    @Override
    public Map<String, Object> getPlayQualifications(Integer userId, Integer productId) {
        return homeDao.getPlayQualifications(userId, productId);
    }
    /**
     * @Description  更新课程的销量
     * @return java.lang.Integer 
     * @Date 2021/12/21 16:57
     **/
    @Override
    public Integer updcourseOrderNum(Integer courseId) {
        Integer upd = homeDao.updcourseOrderNum(courseId,2);
        if(upd!=0){
            Integer updaate = homeDao.updUserLookNum(courseId);
        }
        return upd;
    }
    /**
     * @Description   分享课程数量+1
     * @return java.lang.Integer
     * @Date 2021/12/21 16:57
     **/
    @Override
    public Integer addCourseSharing(Integer id) {
        Integer integer = homeDao.addCourseSharing(id);
        return  integer;
    }
    /**
     * @Description  查看教师的详细信息
     * @return java.util.Map<java.lang.String,java.lang.Object>
     * @Date 2021/12/29 17:59
     **/
    @Override
    public Map<String, Object> selTeaInfo(Integer userId,Integer type) {
        Map<String,Object> map = new HashMap<>();
        if(type==2){//前
            SyBeforeUser beforeUser = homeDao.selBeforeUserInfo(userId);
            map.put("userId",beforeUser.getUserId());
            map.put("trueName",beforeUser.getRealName());
            if(beforeUser.getAvatarUrl()!=null && beforeUser.getAvatarUrl().length()!=0 && beforeUser.getAvatarUrl()!="null"){
                if(beforeUser.getAvatarUrl().indexOf("http") == -1){
                    map.put("avatarUrl",path+beforeUser.getAvatarUrl());
                }
            }
            map.put("freestyle",beforeUser.getRemarks());
            return map;
        }else{//后
            Map<String, Object> map2 = homeDao.selTeaInfo(userId);
            String avatarUrl = (String) map2.get("avatarUrl");
            if(avatarUrl!=null && avatarUrl.length()!=0 && avatarUrl!="null"){
                if(avatarUrl.indexOf("http") == -1){
                    map2.put("avatarUrl",path+avatarUrl);
                }
            }
            return map2;
        }
    }

    /**
     * @Description  查询指定人物的课程
     * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
     * @Date 2021/12/29 18:49
     **/
    @Override
    public List<Map<String, Object>> selCourseUserInfo(Integer userId, Integer type) {
        return homeDao.selCourseUserInfo(userId, type);
    }

    /**
     * @Description  添加商品订单时候，添加商品的收货地址
     * @return java.util.Map<java.lang.String,java.lang.Object>
     * @Date 2022/1/14 13:30
     **/
    @Override
    public Map<String, Object> selPrUserAddress(Integer productId) {
        return homeDao.selPrUserAddress(productId);
    }
}
